package server;

import java.util.HashMap;
import java.util.Map;

/**
 * This class manages usernames and passwords.
 * It retrives all the logins and passwords from a file, and allows searching
 * and retriving usernames and passwords.
 * @author c8yanche
 */
public class UserManager {

    private Map<String, String> userMap = new HashMap<String, String>();

    /**
     * Create a UserManager from a given login data file.
     * @param dataFile the path of the text file that stores user information.
     */
    public UserManager (String dataFile) {
        //TODO.
    }

    /**
     * Testing only.
     */
    public UserManager (){
        userMap.put("OCBNremotelab", "BiomarkerFTW");
        userMap.put("Chen", "GlobusPallidus");
        userMap.put("Tester", "RandomTester");

    }

    /**
     * Determines whether a username exists in the datafile.
     * @param uname the username to be search.
     * @return true if the username exists, false if not.
     */
    public boolean isValidUser(String uname){
        return userMap.containsKey(uname);
    }

    /**
     * Get the password for a given user.
     * @param uname the username for the user.
     * @return a String, the password (private key) for the user.
     */
    public String getPrivKey(String uname){
        return userMap.get(uname);
    }

}
